from internal_page import InternalPage
from selenium.webdriver.support.expected_conditions import *
from selenium.webdriver.common.by import By

class FilmListPage(InternalPage):

    @property
    def movie_boxes(self):
        return self.driver.find_elements_by_class_name("movie_box")

    @property
    def add_button(self):
        return self.driver.find_elements_by_class_name("button")[0].find_element_by_tag_name("a")

    @property
    def search_field(self):
        return self.driver.find_element_by_id("q")

    @property
    def search_results(self):
        self.wait.until(invisibility_of_element_located((By.CLASS_NAME, "content")))

    @property
    def no_search_results(self):
        self.wait.until(presence_of_element_located((By.CLASS_NAME, "content")))

    @property
    def no_search_results_and_check_message(self):
        self.wait.until(text_to_be_present_in_element((By.CLASS_NAME, "content"), "No movies where found."))